<?php
/**
 * Created by PhpStorm.
 * User: wodrow
 * Date: 2018/9/30
 * Time: 17:29
 */

/**
 * @var \yii\web\View $this
 * @var \common\models\db\Docu $model
 * @var \home\modules\docu\models\FormComment $form_comment
 * @var \home\modules\docu\models\FormLookPwd $form_look_pwd
 * @var \yii\data\ActiveDataProvider $commentDataProvider
 * @var \home\modules\docu\models\FormCommentReply $form_reply
 * @var \common\models\db\DocuCommentReply $reply_query
 */

use common\components\tools\Html;
use kartik\icons\Icon;
use kartik\form\ActiveForm;
use yii\widgets\Pjax;
use common\components\widgets\JsBlock;
use yii\widgets\ListView;
use common\rewrite\widgets\LinkPager;
use yii\captcha\Captcha;
use yii\data\ActiveDataProvider;

$this->title = $model->title;
$this->params['breadcrumbs'][] = Html::a(\common\models\db\Docu::getTypes()[$model->type].'列表', $model->listUrl);
$this->params['breadcrumbs'][] = $this->title;
?>

    <div class="home-docu-news-view">
        <div class="row">
            <!-- Blog Post Content Column -->
            <div class="col-sm-12">
                <!-- Blog Post -->
                <hr>
                <!-- Date/Time -->
                <p>
                    <?= Icon::show('clock-o') ?>
                    发布于 <?= date("Y-m-d H:i", $model->created_at) ?>
                    <?= Icon::show('user-circle-o') ?>
                    发布者 <?=$model->createdBy->getProfileBoxA($model->createdBy->profileName) ?>
                </p>
                <hr>

                <?php if ($model->pre_logo): ?>
                    <!-- Preview Image -->
                    <?= Html::img($model->pre_logo, ['class' => "img-responsive"]) ?>
                    <hr>
                <?php endif; ?>

                <!-- Post Content -->
                <p class="lead"><?= $model->desc ?></p>
                <div class="docu-body-view-div">
                    <?php if (!$model->canLook): ?>
                    <?php $model->look_pwd = null; ?>
                    <?php $form_lp = ActiveForm::begin(['type' => ActiveForm::TYPE_INLINE]); ?>
                    <?=$form_lp->field($form_look_pwd, 'pwd')->passwordInput(); ?>
                    <?= Html::submitButton("确定", ['class' => "btn btn-primary"]); ?>
                    <?php ActiveForm::end(); ?>
                    <?php else: ?>
                    <?= $model->body ?>
                    <?php endif; ?>
                </div>
                <hr>

                <!-- Blog Comments -->

                <?php Pjax::begin(); ?>
                <?=$this->render('/public/_comment', [
                    'model' => $model,
                    'form_comment' => $form_comment,
                    'commentDataProvider' => $commentDataProvider,
                    'form_reply' => $form_reply,
                    'reply_query' => $reply_query,
                ]) ?>
                <?php Pjax::end(); ?>
            </div>

        </div>
    </div>


<?php JsBlock::begin(); ?>
    <script>
        $("document").ready(function () {
            $(document).on('click', '.comment_reply_btn', function () {
                $('.media-reply-form').hide();
                $(this).parents(".media-comment-list").find(".media-reply-form").show();
            });
        });
    </script>
<?php JsBlock::end(); ?>